// 引入工具类
import request from '@/utils/request.js';
import md5 from "@/utils/md5.js";

export function updatePDA(data) {
	return request({
		url: getApp().globalData.baseUrl + 'pub/execProc/updatePDA',
		method: 'post',
		data: data
	})
}

export function login(data) {
	return request({
		url: getApp().globalData.baseUrl + 'MES/SandCoreOffline',
		method: 'post',
		data: {
			usercode: data.usercode,
			password: md5.hex_md5(data.password)
		}
	})
}

export function getAllUser(data) {
	return request({
		url: getApp().globalData.baseUrl + 'sys/listUser',
		method: 'post',
		data: {
			 operator:{
				code:"",//操作者编码
				name:"",//不是必须的
			 },
			busiData: {
				usercode:data.usercode,//用户编码
				username:data.username,//用户名称
			}
        },
	})
}

export function resetUserP(data) {
	return request({
		url: getApp().globalData.baseUrl + 'sys/resetPassword',
		method: 'post',
		data: {
			 operator:{
				code:uni.getStorageSync("usercode"),//操作者编码
				name:uni.getStorageSync("username"),//不是必须的
			 },
			busiData: {
				id:data.id,//用户编码
			},
        },
	})
}

export function delUser(data) {
	return request({
		url: getApp().globalData.baseUrl + 'sys/deleteUser',
		method: 'post',
		data: {
			 operator:{
				code:uni.getStorageSync("usercode"),//操作者编码
				name:uni.getStorageSync("username"),//不是必须的
			 },
			busiData: {
				id:data.id,//用户编码
			},
        },
	})
}

export function editPasswd(data) {
	return request({
		url: getApp().globalData.baseUrl + 'sys/updatePassword',
		method: 'post',
		data: 
		{
			operator:{
				code:uni.getStorageSync("usercode"),//操作者编码
				name:uni.getStorageSync("username"),//不是必须的
			},
			busiData: {
				usercode:data.userCode,//用户编码
				oldPassword:md5.hex_md5(data.oldPassword),//用户名称
				newPassword: md5.hex_md5(data.newPassword), //新密码
				surePassword: md5.hex_md5(data.checkNewPassword) //第二次新密码
			}
		}
	})
}

export function addUser(data) {
	return request({
		url: getApp().globalData.baseUrl + 'sys/createUser',
		method: 'post',
		data: {
			 operator:{
				code:uni.getStorageSync("usercode"),//操作者编码
				name:uni.getStorageSync("username"),//不是必须的
			 },
			busiData: {
				usercode:data.usercode,//用户编码
				username:data.username,//用户名称
			}
        },
	})
}
